<template>
	<view class="container p30">
		<view class="header">
			<view>累计提现</view>
			<view>￥<text>{{wallert_info.takeout_money}}</text></view>
		</view>
		<!--  提现记录 -->
		<scroll-view class="recordList" scroll-y="true" @scrolltolower="onBottom">
			<template v-for="item in list">
				<view class="item" :key="item.id">
					<view class="avator"><image src="https://community.chuangxiangdianli.com/images/neighborimg/market/mine/wallert/weiixn.png" mode=""></image></view>
					<view class="content">
						<view class="time">申请时间  {{item.created_at}}</view>
						<view class="money">提现金额 <text>￥{{item.money}}</text></view>
					</view>
					<view class="status">
						<image v-if="item.state==2" src="https://community.chuangxiangdianli.com/images/neighborimg/market/mine/wallert/weiixn.png" mode=""></image>
						<view v-else="item.state==">{{item.state==1?'待审核':'已拒绝'}}</view>
					</view>
				</view>
			</template>
			<u-loadmore :status="status" />
		</scroll-view>
	</view>
</template>

<script>
	// 引入封装的请求
	import request from '@/utils/request.js'	
	export default{
		data(){
			return {
				wallert_info:{
					flea_money:0,
					amount_income:0,
					takeout_money:0
				},
				// 提现记录
				list:[],
				// 当前页码
				pageNo:1,
				// 当前的数据条数
				limit:10,
				// 是否正在请求数据
				is_loading:false,
				// 是否请求完数据
				is_bottom:false,
				// 底部正在加载中
				status: 'loadmore'
			}
		},
		onShow() {
			this.get_wallert_info()
			this.get_list()
		},
		
		methods:{
			// 获取钱包信息
			get_wallert_info(){
				let that = this
				request.get('Mini/circle/flea/fleaWallet').then(res=>{
					if(res.code==200){
						that.wallert_info = res.data
					}
				})
			},
			// 获取提现记录
			get_list(turn){
				let that = this
				that.is_loading = true
				request.get('Mini/circle/flea/withdrawalList',{
					page:that.pageNo,
					limit:that.limit
				}).then(res => {
					console.log('首页数据', res)
					that.is_loading = false
					if (res.code==200) {
						if(turn){
							if(res.data.data.length>0){
								that.list = [
									...that.list,
									...res.data.data
								]
							}
						}else{
							that.list = res.data.data
						}
						
						if(res.data.count==that.list.length){
							// that.is_boottom = true
							that.status = 'nomore';
						}
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				}).catch(res => {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
				})
			},
			// 底部加载数据 
			onBottom(){
				let that = this
				this.status = 'loading';
				// console.log(11111)
				if(that.status = 'nomore' || that.is_loading){
					return false
				}
				this.pageNo++
				setTimeout(() => {
					that.get_list(true)
				}, 1000)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.header{
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		width: 100%;
		height: 200rpx;
		border-radius: 20rpx;
		background: linear-gradient(-28deg, #0BBAFB, #4285EC);
		margin-bottom: 20rpx;
		&>view:nth-child(1){
			font-size: 34rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
		}
		&>view:nth-child(2){
			margin-top: 25rpx;
			font-size: 34rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
			&>text{
				font-size: 48rpx;
			}
		}
	}
	.recordList{
		height: calc(100% - 220rpx);
		.item{
			display: flex;
			flex-direction: row;
			justify-content: flex-start;
			align-items: center;
			height: 156rpx;
			background: #FFFFFF;
			box-shadow: 0px 7px 8px 0px rgba(203, 203, 203, 0.19);
			border-radius: 20rpx;
			margin-bottom: 18rpx;
			padding: 24rpx 35rpx 39rpx;
			// box-sizing: border-box;
			.avator{
				height: 74rpx;
				width: 74rpx;
				&>image{
					display: block;
					height: 100%;
					width: 100%;
				}
			}
			.content{
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				height: 100%;
				margin: 0 33rpx;
				.time{
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #999999;
				}
				.money{
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #333333;
					&>text{
						color: rgba(210, 37, 37, 1);
					}
				}
			}
			.status{
				height: 45rpx;
				text-align: center;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: 500;
				line-height: 45rpx;
				color: #999999;
				&>image{
					display: block;
					height: 45rpx;
					width: 45rpx;
				}
				
			}
		}
	}
</style>
